package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsCollectMapper;
import com.qf.pojo.DtsCollect;
import com.qf.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class CollectServiceImpl implements CollectService {
    @Autowired
    private DtsCollectMapper dtsCollectMapper;


    @Override
    public IPage<DtsCollect> findListByQuery(Integer page, Integer limit, Integer userId, Integer valueId, String sort, String order) {
        return dtsCollectMapper.selectPage(new Page<>(page,limit),new QueryWrapper<DtsCollect>()
                .eq(userId!=null,"user_id",userId)
                .eq(valueId!=null,"value_id",valueId)
                .eq("deleted",false)
                .orderBy(!StringUtils.isEmpty(sort),"ASC".equalsIgnoreCase(order),sort));
    }
}
